<!--废弃，不使用-->
<% include ../header.ejs %>


<link rel="stylesheet" href="/stylesheets/app/address/address.css">

<header data-am-widget="header" data-am-sticky class="am-header am-header-default" id="appTemplates-Nav">

    <div class="am-header-left am-header-nav">
        <a href='javascript:history.go(-1)' class="">
            <img class="am-header-icon-custom"
                 src="data:image/svg+xml;charset&#x3D;utf-8,&lt;svg xmlns&#x3D;&quot;http://www.w3.org/2000/svg&quot; viewBox&#x3D;&quot;0 0 12 20&quot;&gt;&lt;path d&#x3D;&quot;M10,0l2,2l-8,8l8,8l-2,2L0,10L10,0z&quot; fill&#x3D;&quot;%23fff&quot;/&gt;&lt;/svg&gt;"
                 alt=""/>
        </a>
    </div>
    <h1 class="am-header-title">
        <a href="#title-link" class="" id="Typeface-whitecolor">卖方</a>
    </h1>


    <div class="am-header-right am-header-nav">
        <a id="custom-add-button" onClick="addClick()">
            <i class="am-header-icon am-icon-plus"></i>
        </a>
    </div>


</header>


<ul class="am-list am-list-border am-list-striped">


    <% list.forEach(function(data, key){ %>
    <li class="am-list-item">
        <a class="am-list-main address-list" href="#detail">
            <span><%= data.name %></span>
            <span class="am-hide"><%= data.rowId %></span>
            <span class="am-fr am-icon-minus-circle"  onclick="remove('<%= data.rowId %>','<%=data.name%>')%>"></span>
        </a>
    </li>
    <% }) %>
</ul>


<div class="am-modal am-modal-prompt" tabindex="-1" id="custom-prompt">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">输入卖方名称</div>
        <div class="am-modal-bd">
            <input type="text" class="am-modal-prompt-input">
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>提交</span>
        </div>
    </div>
</div>


<div class="am-modal am-modal-prompt" tabindex="-1" id="del-prompt">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">删除卖方</div>
        <div class="am-modal-bd">
         <label id="lbDel"></label>
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>


<div class="am-modal am-modal-prompt" tabindex="-1" id="alert-prompt">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">提示</div>
        <div class="am-modal-bd">
            <label id="lbMsg"></label>
        </div>
        <div class="am-modal-footer">

            <span class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>

<script>


    function showMsg(msg){
        $('#lbMsg').text(msg);

        $('#alert-prompt').modal({
            relatedElement: this,
            onConfirm: function (e) {

                   window.location.reload();

                return false;
            },
            onCancel: function () {


            }
        });
    }
    function showMsgNoRefresh(msg){
        $('#lbMsg').text(msg);

        $('#alert-prompt').modal({
            relatedElement: this,
            onConfirm: function (e) {



                return false;
            },
            onCancel: function () {


            }
        });
    }
    function addClick() {

        $('#custom-prompt').modal({
            relatedElement: this,
            onConfirm: function (e) {
//                showMsg('你输入的是：' + e.data,false);

                var options = {
                    url: 'saveSeller',
                    type: 'post',
                    dataType: 'json',
                    data: {'seller': e.data},
                    error: function (request) {
                        showMsgNoRefresh("添加失败");
                    },
                    success: function (data) {
//                       alert(data.isCreated);

                        if (data.isCreated && data.isCreated == 1) {


                            showMsg("添加成功");

                        } else {
                            showMsgNoRefresh("添加失败");
                        }
                    }
                };
                $.ajax(options);
                return false;
            },
            onCancel: function () {


            }
        });
    }

    function remove(rowId,name) {

    $('#lbDel').text("确定删除:  "+name);

        $('#del-prompt').modal({
            relatedElement: this,
            onConfirm: function (e) {
//                alert(rowId+name);

                var options = {
                    url: 'delSeller',
                    type: 'post',
                    dataType: 'json',
                    data: {'rowId': rowId},
                    error: function (request) {
                        showMsgNoRefresh("删除失败");
                    },
                    success: function (data) {
                        if (data.isDel && data.isDel == 1) {
                            showMsg("删除成功");

                        } else {
                            showMsgNoRefresh("删除失败");
                        }
                    }
                };
                $.ajax(options);
                return false;
            },
            onCancel: function () {


            }
        });
    }

</script>

<% include ../footer.ejs %>